package io.github.lee.jel.global.di.http.interceptor

import android.util.Log
import okhttp3.Interceptor
import okhttp3.Response


class PublicParameterInterceptor(private val accessToken: String) : Interceptor {
    override fun intercept(chain: Interceptor.Chain): Response {
        val rawRequest = chain.request()
        Log.e("tag", "API KEY = ${accessToken}")
        when (rawRequest.method) {
            "GET" -> {
                val url = rawRequest.url.newBuilder()
                    .addEncodedQueryParameter("api_key", accessToken)
                    .build()
                val request = rawRequest.newBuilder()
                    .url(url)
                    .build()
                return chain.proceed(request)
            }

            "POST" -> {
                rawRequest.body

            }
        }


        return chain.proceed(rawRequest)
    }

    private fun get() {

    }

}